// 
// Copyright 2010 Classpath Pty Ltd <opensource@classpath.com.au>
// 
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// 
//     http://www.apache.org/licenses/LICENSE-2.0
// 
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// 

**
** Represents the ability to use a column type from within part of a column change.
**
mixin CanUseColumnType {

    **
    ** Creates a `BlobType` for use as a `ColumnType`.
    **
    BlobType blob() {
        Pod.of(this).log.debug("${typeof}.blob - start")
        Pod.of(this).log.warn("Warning - blob is a mysql only type")
        type := BlobType()
        Pod.of(this).log.debug("${typeof}.blob - end - returning ${type}")
        return type
    }

    **
    ** Creates a `CharType` with the (optionally) specified length for use as a `ColumnType`.
    **
    CharType char(Int length := 0) {
        Pod.of(this).log.debug("${typeof}.char(${length}) - start")
        type := CharType(length)
        Pod.of(this).log.debug("${typeof}.char(${length}) - end - returning ${type}")
        return type
    }

    **
    ** Creates a `DateType` for use as a `ColumnType`.
    **
    DateType date() {
        Pod.of(this).log.debug("${typeof}.date - start")
        type := DateType()
        Pod.of(this).log.debug("${typeof}.date - end - returning ${type}")
        return type
    }

    **
    ** Creates a `DecimalType` with the (optionally) specified precision and scale for use as a `ColumnType`.
    **
    DecimalType decimal(Int precision := 0, Int scale := 0) {
        Pod.of(this).log.debug("${typeof}.decimal(${precision}, ${scale}) - start")
        type := DecimalType(precision, scale)
        Pod.of(this).log.debug("${typeof}.decimal(${precision}, ${scale}) - end - returning ${type}")
        return type
    }

    **
    ** Creates a `DoubleType` with the (optionally) specified precision and scale for use as a `ColumnType`.
    **
    DoubleType double(Int precision := 0, Int scale := 0) {
        Pod.of(this).log.debug("${typeof}.double(${precision}, ${scale}) - start")
        Pod.of(this).log.warn("Warning - double is a mysql only type")
        type := DoubleType(precision, scale)
        Pod.of(this).log.debug("${typeof}.double(${precision}, ${scale}) - end - returning ${type}")
        return type
    }

    **
    ** Creates a `FloatType` with the (optionally) specified precision and scale for use as a `ColumnType`.
    **
    FloatType float(Int precision := 0, Int scale := 0) {
        Pod.of(this).log.debug("${typeof}.float(${precision}, ${scale}) - start")
        type := FloatType(precision, scale)
        Pod.of(this).log.debug("${typeof}.float(${precision}, ${scale}) - end - returning ${type}")
        return type
    }

    **
    ** Creates a `IntegerType` with the (optionally) specified precision for use as a `ColumnType`.
    **
    IntegerType integer(Int precision := 0) {
        Pod.of(this).log.debug("${typeof}.integer(${precision}) - start")
        type := IntegerType(precision)
        Pod.of(this).log.debug("${typeof}.integer(${precision}) - end - returning ${type}")
        return type
    }

    **
    ** Creates a `SerialType` for use as a `ColumnType`.
    **
    SerialType serial() {
        Pod.of(this).log.debug("${typeof}.serial - start")
        type := SerialType()
        Pod.of(this).log.debug("${typeof}.serial - end - returning ${type}")
        return type
    }

    **
    ** Creates a `TextType` for use as a `ColumnType`.
    **
    TextType text() {
        Pod.of(this).log.debug("${typeof}.text - start")
        type := TextType()
        Pod.of(this).log.debug("${typeof}.text - end - returning ${type}")
        return type
    }

    **
    ** Creates a `TimestampType` for use as a `ColumnType`.
    **
    TimestampType timestamp() {
        Pod.of(this).log.debug("${typeof}.timestamp - start")
        type := TimestampType()
        Pod.of(this).log.debug("${typeof}.timestamp - end - returning ${type}")
        return type
    }

    **
    ** Creates a `TimeType` for use as a `ColumnType`.
    **
    TimeType time() {
        Pod.of(this).log.debug("${typeof}.time - start")
        type := TimeType()
        Pod.of(this).log.debug("${typeof}.time - end - returning ${type}")
        return type
    }

    **
    ** Creates a `VarcharType` with the (optionally) specified length for use as a `ColumnType`.
    **
    VarcharType varchar(Int length := 0) {
        Pod.of(this).log.debug("${typeof}.varchar(${length}) - start")
        type := VarcharType(length)
        Pod.of(this).log.debug("${typeof}.varchar(${length}) - end - returning ${type}")
        return type
    }

}
